package com.hackerrank.challenges.thelovelettermystery;

import java.util.Scanner;

public class Solution {
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int T = in.nextInt();
		in.nextLine();
		for(int t = 0; t < T; t++) {
			String s = in.nextLine();
			char c[] = s.toCharArray();
			int n = 0;
			for(int i = 0; i < c.length / 2; i++) {
				n += Math.abs(c[i] - c[c.length - i - 1]);
			}
			System.out.println(n);
		}
	}
}
